<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ page language="java" isELIgnored="false" import="java.util.*" pageEncoding="UTF-8" contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt"%>
<% response.setHeader("Pragma","No-cache"); 

response.setHeader("Cache-Control","no-cache"); 

response.setDateHeader("Expires", 0); %> 
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<META HTTP-EQUIV="pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Cache-Control" CONTENT="no-cache, must-revalidate">
<title>修改运价预警设置</title>

<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/show.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/jquery-1.6.4.min.js"></script>
<script type="text/javascript" src="<%=request.getContextPath() %>/fare/js/datePicker/WdatePicker.js"></script>
<link href="<%=request.getContextPath()%>/fare/js/cityquery/cityquery.css" rel="stylesheet" type="text/css" />
<script src="<%=request.getContextPath()%>/fare/js/cityquery/citylist.js" type="text/javascript"></script>
<script type='text/javascript' src='<%=request.getContextPath()%>/fare/js/cityquery/querycity.js'></script>

<link href="<%=request.getContextPath() %>/fare/css/base.css" rel="stylesheet" type="text/css" />

</head>
<script type="text/javascript">
var flag=false;
/* $(function(){
	//$('#flightFrom').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	//$('#flightTo').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	
	//$('#_flightFrom').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	//$('#_flightTo').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	
	//$('#flightFrom0').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
	//$('#flightTo0').querycity({'data':citysFlight,'tabs':labelFromcity,'hotList':hotList});
}); */

//判断 是否修改过？？？？？
function checkIfUpdate(){
	flag=true;
}
function closeWindow(){
	if(window.confirm("您确定要关闭当前窗口吗?")){
		window.close();
	}
}

//==========================================================
function modify(){
	if(flag==false){
		alert("请修改信息后再保存");
		return false;
	}
	
	//航段
	var flightFrom = $("#flightFrom0").val();
	var flightTo = $("#flightTo0").val();
	
	if(flightFrom=="" || flightTo =="" || flightFrom=="中文/拼音" || flightTo =="中文/拼音"){
		alert("航段不能为空");
		return false;
	}
	if(flightFrom==flightTo){
		alert("出发地与目的地不能相同");
		return false;
	}
	//有效时间的比较
	var effectiveFrom = $("#effectiveFrom0").val();
	var effectiveTo   = $("#effectiveTo0").val();
	if(effectiveFrom == null  ||  effectiveTo==null || effectiveFrom=="" || effectiveTo==""){
		alert("时间未填写");
		return false;
	}
	var s_date = new Date(effectiveFrom.replace(/-/g,"/"));
    var e_date = new Date(effectiveTo.replace(/-/g,"/"));
    var time1 = s_date.getTime();
	var time2 = e_date.getTime();
	if(time1>time2){
		alert("结束时间不能小于开始时间");
		return false;
	}
	
	//触发条件的比较
	//alert("触发条件比较啊");
    var futureDays = $("#futureDays").val();
    var triggerCondition = $("#triggerCondition").val();
    if(futureDays==null||futureDays==''||triggerCondition==null||triggerCondition==''){
    	alert('触发条件未填写');
    	return false;
    }
	 if(!(/(^[1-9]\d*$)/.test(futureDays))){
    	alert("天数不为正整数");
    	$("#futureDays").val('');
    	return false;
    }
    
    if(parseInt(futureDays)>30||parseInt(futureDays)<1){
    	alert("未来天数范围1~30");
    	return false;
    }
    
    //触发 条件 天数为正整数
    if(!(/(^[1-9]\d*$)/.test(triggerCondition))){
    	alert("天数不为正整数");
    	$("#triggerCondition").val('');
    	return false;
    }
    
    if(futureDays!=null&&triggerCondition!=null){
    	var conditionTime=parseInt(triggerCondition);//触发时间
    	var futureTime=parseInt(futureDays);
    	if((futureTime+1)<conditionTime&&conditionTime>1){
    		alert("触发条件可填的最大值为未来天数+1，最小数为1");
    		return false;
    	};
    }
	
	//alert("触发条件比较啊");
	
	$.post('freightPriceAnalyseAlertConfigAction!updateFreightPriceAnalyseAlertConfigStats.action',
			$("#editForm").serialize(),
			function(data){
		if(data && data=="succes"){
			alert('修改成功');
			window.close();
			window.returnValue = "ok";
		}else{
			alert('修改失败!原因:'+data);
		}
	},'text'); 
}
//==========================================================
</script>
<body>
<!-- 修改  -->
   <div id="edit">
		<form id="editForm" method="post">
			<input type="hidden" id="ids" name="id" value="${vo.id}"/>
			<input type="hidden" id="creator0" name="creator" value="${vo.creator}"/>
			<input type="hidden" id="creatorName0" name="creatorName" value="${vo.creatorName}"/>
			<input type="hidden" id="createTime0" name="oldcreateTime" value="${vo.createTime}"/>
		
			<TABLE cellSpacing=1 cellPadding=3 width="100%" border=0 class="tabg">
					<TR class="tr1">
						<TD colspan="10" style="color:white">运价预警配置</TD>
					</TR>
					<TR class="tab">
						<TD width="100" height="100" style="text-align: left" class="td1">
							说&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;明：</TD>
						<TD colspan="3">1、带红色 <font color="red">&nbsp;&nbsp;&nbsp;&nbsp;*</font>号的为必填项:<br/>
							2、用户在设置运价预警规则后，当运价差额比例符合指定触发条件时，系统自动发消息(邮件/短信)给制定该规则的用户；<br/>
							3、同一航空公司下相同航线有且只有一条航线预警配置。<br/>
							4、用户预警方式中，目前只支持邮件提醒。<br/>
						</TD>
					</TR>
					
				<TR class="tab">
				<TD class="left" width="20%" height="26" style="text-align:left">
					航空公司：
					<span style="color: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>
			    </TD>
			    
			    <TD colspan="3">
			       <select name="airCompany" style="width: 150px;" id="airCompany0">
						<c:choose>
							<c:when test="${tempList == null}">
							</c:when>
							<c:otherwise>
								<c:forEach var="item" items="${tempList}">
									<option value="${item.name}">${item.name}</option>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</select>
			    </TD>
			 </TR>
			    
			 <TR class="tab">
			    <TD class="left" style="text-align:left">
			    		航&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;段：
			    		<font color="red">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</font>
			    </TD>
			    
			    <TD>
			      <span>从</span>
			      	<input type="text" style="width:100px" name="flightFrom" id="flightFrom0" value="${vo.fromCityName}"  readOnly="readOnly"/>
			      <span>到</span>
			      	<input type="text" style="width:100px" name="flightTo" id="flightTo0" value="${vo.toCityName}"  readOnly="readOnly"/>
			    </TD>
			  </TR>
			  
			  <TR class="tab">
			  	<TD width="120" height="26" class="left" style="text-align:left">
			  		预警方式：
			  		<span style="color: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>
			    </TD>
			    
			    <TD >
			      	<select name="alertWay" style="width: 150px;" id="alertWay0" disabled="disabled">
							<option value="1" selected="selected">邮件</option>
							<option value="0">短信</option>
					</select>
			    </TD>
			  </TR>
			  
			  <TR class="tab">
			    <TD height="26" class="left" style="text-align:left">
			    	预警有效期：<font color="red">&nbsp;&nbsp;*</font>
			    </TD>
			    <TD>
			      <span>从</span>
			      <input type="text" style="width:150px" id="effectiveFrom0" name="effectiveFrom"  
			        onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd',minDate:'%y-%M-{%d+1}'});" 
			        value="${vo.startTimeString}" readonly="readonly" onchange="checkIfUpdate()">
			      <span>到</span>
			      <input type="text" style="width:150px" id="effectiveTo0" name="effectiveTo" 
			        onClick="WdatePicker({skin:'whyGreen',dateFmt:'yyyy-MM-dd',minDate:'%y-%M-{%d+1}'});" 
			        value="${vo.endTimeString}" readonly="readonly" onchange="checkIfUpdate()">
				</TD>
			  </TR>
			  
			  <TR>
			  	<TD width="120" height="26" class="left" style="text-align:left">
			  		触发条件：<span style="color: #ff0000">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;*</span>
   				</TD>
    			<TD colspan="2" width="120" height="26" style="text-align:left">
    				该航线在未来
				    <input type="text" style="width:50px" name="futureDays" 
				    		id="futureDays" value="${vo.futureDays}" onchange="checkIfUpdate()"/>
					天的价格有 
					<input type="text" style="width:50px" name="triggerCondition" 
							id="triggerCondition" value="${vo.triggerCondition}" onchange="checkIfUpdate()">
					天以
					<select class="easyui-combobox" name="chooseUpOrdown" id="up_down" disabled="disabled">
						<option value="0" selected="selected">下</option>
						<option value="1" >上</option>
					</select>
					是最低价
   				</TD>
   				
			  <TR class="tab">
				  <TD colspan="2" style="text-align:center;height:35px;">
					    <input type="button" style="width:80px" id="btnSave" name="btnSave" value="保存" onclick="modify()" />
			  			<input type="reset" style="width:80px" id="btnReset" name="btnReset" value="重置"/>
			  			<input type="button" style="width:80px" id="btnClose" name="btnClose" value="关闭" onclick="closeWindow();" /> 
				  </TD>
			  </TR>

		</TABLE>
		</form>
	</div>
	
	<!-- 回显下拉框默认选中项 
	<script>checkDropListItem(document.getElementById("airCompany0"),'${vo.airCompany}');
	
	function checkDropListItem(obj,itemvalue)
	{
	 /*
	 默认选中下拉列表框中的具有某个值的一项
	 obj：下拉列表框对象
	 itemvalue：该项值
	 */
	 for(i=0;i<obj.options.length;i++)
	 {
	  if(obj.options[i].value==itemvalue)
	     obj.selectedIndex=i;
	 }
	}
	</script>-->
	
</body>
</html>